package com.itbaizhan.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itbaizhan.domain.User;
import com.itbaizhan.mapper.UserMapper;
import com.itbaizhan.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.TimeUnit;

/**
* @author 13487
* @description 针对表【user】的数据库操作Service实现
* @createDate 2024-04-26 17:01:12
*/
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
    implements UserService{

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
        return baseMapper.selectList(null);
    }

    @Override
    public User findById(Long id) {
        return baseMapper.selectById(id);
    }

    @Override
    public int insert(String name, Integer age) {
        User user = new User();
        user.setName(name);
        user.setAge(age);
        int result = baseMapper.insert(user);
        return result;
    }

    @Override
    public int update(User user) {
//        return baseMapper.updateById(user);
        return userMapper.updateAge(user.getId(), user.getVersion());
    }
}




